#include "stdafx.h"
#include "CppUnitTest.h"
#include "../Stack/my_stack.h"

using namespace Microsoft::VisualStudio::CppUnitTestFramework;

namespace UnitTest1
{		
	TEST_CLASS(UnitTest1)
	{
	public:
		
		TEST_METHOD(Test_my_stack_capacity)
		{
			my_stack ms1;
			Assert::AreEqual(10, ms1.capacity());
			my_stack ms2(50);
			Assert::AreEqual(50, ms2.capacity());
		}

		TEST_METHOD(Test_my_stack_push_top)
		{
			my_stack ms;
			ms.push(10);
			Assert::AreEqual(10, ms.top());
			ms.push(9);
			Assert::AreEqual(9, ms.top());
			ms.push(8);
			Assert::AreEqual(8, ms.top());
			ms.push(7);
			Assert::AreEqual(7, ms.top());
			ms.push(6);
			Assert::AreEqual(6, ms.top());
			ms.push(5);
			Assert::AreEqual(5, ms.top());
		}

		TEST_METHOD(Test_my_stack_push_top_pop)
		{
			my_stack ms;
			ms.push(10);
			Assert::AreEqual(10, ms.top());
			ms.push(9);
			Assert::AreEqual(9, ms.top());
			ms.push(8);
			Assert::AreEqual(8, ms.top());
			ms.push(7);
			Assert::AreEqual(7, ms.top());
			ms.push(6);
			Assert::AreEqual(6, ms.top());
			ms.push(5);
			Assert::AreEqual(5, ms.top());
			ms.pop();
			Assert::AreEqual(6, ms.top());
			ms.pop();
			Assert::AreEqual(7, ms.top());
			ms.pop();
			Assert::AreEqual(8, ms.top());
			ms.pop();
			Assert::AreEqual(9, ms.top());
			ms.pop();
			Assert::AreEqual(10, ms.top());
		}

		TEST_METHOD(Test_my_stack_size)
		{
			my_stack ms;
			ms.push(1);
			ms.push(2);
			ms.push(3);
			ms.push(4);
			Assert::AreEqual(4, ms.size());
		}

		TEST_METHOD(Test_my_stack_operator_equals)
		{
			my_stack ms1;
			ms1.push(1);
			ms1.push(2);
			ms1.push(3);
			ms1.push(4);
			Assert::AreEqual(4, ms1.size());
			Assert::AreEqual(4, ms1.top());

			my_stack ms2;
			ms2 = ms1;
			Assert::AreEqual(4, ms2.size());
			Assert::AreEqual(4, ms2.top());

			ms1.push(5);
			ms1.push(6);
			Assert::AreEqual(6, ms1.size());

			Assert::AreEqual(4, ms2.size());
		}

		TEST_METHOD(Test_my_stack_copy_constructor)
		{
			my_stack ms1;
			ms1.push(1);
			ms1.push(2);
			ms1.push(3);
			ms1.push(4);
			Assert::AreEqual(4, ms1.size());
			Assert::AreEqual(4, ms1.top());

			my_stack ms2(ms1);
			Assert::AreEqual(4, ms2.size());
			Assert::AreEqual(4, ms2.top());

			ms1.push(5);
			ms1.push(6);
			Assert::AreEqual(6, ms1.size());

			Assert::AreEqual(4, ms2.size());
		}

		TEST_METHOD(Test_my_stack_iterator)
		{
			my_stack ms;

			ms.push(1);
			ms.push(2);
			ms.push(3);
			ms.push(4);
			ms.push(5);

			int i = 5;

			for (auto it = ms.begin(); it != ms.end(); it++){
				Assert::AreEqual(i, it->value);
				i--;
			}
		}



	};
}